package com.fuce.one.deploy.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.fuce.one.deploy.common.base.BaseController;
import com.fuce.one.deploy.model.TsysUser;


/**
 * 后台方法
 * @ClassName: HomeController
 * @author fuce
 * @date 2019-10-21 00:10
 *
 */
@Controller
@RequestMapping("/admin")
public class AdminController extends BaseController{
	
	private String prefix = "admin";
	
	
	/**
	 * 首页登录
	 * @return
	 * @author fuce
	 * @Date 2020年3月8日 下午8:45:47
	 */
	@GetMapping("/index")
	public String index() {
		return prefix+"/index";
	}
	
	
	/**
	 * 用户登陆验证
	 * @param user
	 * @param rcode
	 * @param redirectAttributes
	 * @param rememberMe
	 * @param model
	 * @param request
	 * @return
	 */
	@PostMapping("/login")
	public String login(TsysUser user) {
		if("admin".equals(user.getUsername())&&"admin".equals(user.getPassword())) {
			return prefix+"/index";
		}else {
			 return "redirect:/login";
		}
	}
	
	/**
	 * 退出登陆
	 * @return
	 */
	@GetMapping("/Loginout")
	public String LoginOut(HttpServletRequest request, HttpServletResponse response){
		
        return "redirect:/login";
	}
}
